home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_aet_fallingdebris.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  116 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_FallingDebris.cog
  4. #
  5. # debris = place a ghost object in the center of your room and put it near the ceiling.
  6. # clutter = place a ghost object in the center of the room at floor level.
  7. #
  8. # turn on this cog from another cog with SendMessage(cogname, user0);
  9. # turn off this cog from another cog with SendMessage(cogname, user1);
  10. #
  11. # [TRM]
  12. #
  13. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  14. # ========================================================================================
  15.  
  16. symbols
  17.  
  18.     message     user0
  19.     message     user1
  20.     message     pulse
  21.     message     timer
  22.     
  23.     thing       debris              # the junk that falls
  24.     thing       clutter             # the junk left on the floor
  25.     
  26.     thing       rocks               local
  27.     thing       scraps              local
  28.     
  29.     sector      tempSect            local
  30.     
  31.     sound       sndFalling=gen_falling_debris_c.wav     local   # falling rocks
  32.     
  33.     template    debris0=stnshrapa_nc_ns         local   # large debris
  34.     template    debris1=stnshrapbm_nc_ns        local   # medium debris
  35.     template    debris2=stnshrapcs_nc_ns        local   # small debris
  36.     template    clutter0=stnshrpa               local   # large clutter
  37.     template    clutter1=stnshrpbm              local   # medium clutter
  38.     template    clutter2=stnshrpcs              local   # small clutter
  39.     
  40.     vector      vecPos              local
  41.     vector      rocksVel            local
  42.     
  43.     int         deb                 local
  44.     int         clut                local
  45.     int         sound1              local
  46.     
  47.     int         numDebris           # how many falling particles to generate w/each pulse.
  48.     int         numClutter          # number of clutter scraps to leave lying on the floor
  49.                                     # set numClutter to 0 for none.
  50.     
  51.     flex        xVal                # x = width of room
  52.     flex        yVal                # y = length of room
  53.     flex        pulseTime=0.25      # duh
  54.     flex        minSndDist          # min distance for debris sfx
  55.     flex        maxSndDist          # max distance for debris sfx
  56.     flex        sndVol              # duh
  57.     
  58. end
  59.  
  60. # ========================================================================================
  61.  
  62. code
  63.  
  64. user0:
  65.  
  66.     SetPulse(pulseTime);
  67.     SetTimer(pulseTime+1.0);
  68.     sound1 = PlaySoundThing(sndFalling, debris, sndVol, minSndDist, maxSndDist, 0x81);
  69.     return;
  70.     
  71. # ========================================================================================
  72.  
  73. user1:
  74.  
  75.     SetPulse(0.0);
  76.     StopSound(sound1, 0.0);
  77.     return;
  78.  
  79. # ========================================================================================
  80.  
  81. pulse:
  82.     
  83.     tempSect = GetThingSector(debris);
  84.     
  85.     SetPulse(0.0);
  86.     for(deb=0; deb<numDebris; deb=deb+1)                                                                        
  87.     {                                                                                                    
  88.         vecPos = VectorSet(rand()*xVal, rand()*yVal, 0.0);
  89.         rocks = CreateThingAtPos(debris0[RandBetween(0, 2)], tempSect, VectorAdd(GetThingPos(debris), VectorAdd('-0.25 -0.25 0.0', vecPos)), '0 0 0');
  90.         rocksVel = VectorSet(0, 0, 0.01);
  91.         SetThingVel(rocks, VectorScale(rocksVel, 0.7));
  92.     }
  93.     SetPulse(pulseTime);
  94.     
  95.     return;
  96.  
  97. # ========================================================================================
  98.  
  99. timer:
  100.  
  101.     if(numClutter == 0) return;
  102.     
  103.     for(clut=0; clut<numClutter; clut=clut+1)                                                                        
  104.     {                                                                                                    
  105.         vecPos = VectorSet(rand()*xVal, rand()*yVal, 0.0);
  106.         scraps = CreateThingAtPos(clutter0[RandBetween(0, 2)], tempSect, VectorAdd(GetThingPos(clutter), VectorAdd('-0.25 -0.25 0.0', vecPos)), '0 0 0');
  107.         Sleep(rand()+0.5);
  108.     }
  109.     
  110.     return;
  111.  
  112. # ========================================================================================
  113.  
  114. end
  115.  
  116.